import { RouterProvider, createHashRouter } from "react-router-dom";
import ReactDOM from "react-dom/client";
import App from "./App.jsx";
import "./index.scss";
import Login from "./pages/Login.jsx";
import Home from "./pages/Home.jsx";
import Medicine from "./pages/Medicine/index.jsx";
import News from "./pages/News/index.jsx";
import User from "./pages/User.jsx";
import Reg from "./pages/Reg.jsx";

import ProtectedRoute from "./components/protected-route.jsx";

const router = createHashRouter([
  {
    path: "/login",
    element: <Login />,
  },
  {
    path: "/reg",
    element: <Reg />,
  },
  {
    path: "/",
    element: <App />,
    children: [
      {
        index: true,
        element: <Home />,
      },
      {
        path: "medicine",
        element: <Medicine />,
      },
      {
        path: "news",
        element: <News />,
      },
      {
        path: "user",
        element: (
          <ProtectedRoute>
            <User />
          </ProtectedRoute>
        ),
      },
    ],
  },
]);

ReactDOM.createRoot(document.getElementById("root")).render(
  <RouterProvider router={router} />
);
